package com.yupi.yupicturebackend.manager.websocket.model;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

@Getter
public enum PictureEditMessageTypeEnum {
    INFO("发送通知", "INFO"),
    ERROR("发送错误", "ERROR"),
    ENTER_EDIT("进入编辑状态", "ENTER_EDIT"),
    EXIT_EDIT("退出编辑状态", "EXIT_EDIT"),
    EDIT_ACTION("执行编辑动作", "EDIT_ACTION");
    private final String text;
    private final String value;

    PictureEditMessageTypeEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }
    /**
     * 根据消息类型值获取对应的枚举实例
     *
     * @param value 消息类型值
     * @return 匹配的枚举实例，若未找到或输入为空则返回 null
     */
    public static PictureEditMessageTypeEnum getByValue(String value) {
       if(StrUtil.isBlank(value)){
           return null;
       }
        for (PictureEditMessageTypeEnum type : PictureEditMessageTypeEnum.values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        return null;
    }
}
